﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace ChatIBOXClient
{
    /// <summary>
    /// Interaction logic for SendMessageWindow.xaml
    /// </summary>
    public partial class SendMessageWindow : Window
    {
        ProxySingleton proxySingleton = null;
        ServiceReference.Client receiver = null;
        public SendMessageWindow()
        {
            receiver = new ChatIBOXClient.ServiceReference.Client();
            receiver.Name = "Khoi1";
            proxySingleton = ProxySingleton.GetInstance();
            InitializeComponent();
            proxySingleton.ProxyCallbackEvent += new ProxySingleton.ProxyCallbackEventHander(this.ProxySingleton_ProxyCallbackEvent);
        }

        public void ProxySingleton_ProxyCallbackEvent(object sender, ProxyCallbackEventArgs e)
        {
            this.textBlockContent.Text = e.message.Content;
            this.textBoxHistory.AppendText(e.message.Content);
        }

        private void buttonSend_Click(object sender, RoutedEventArgs e)
        {
            ServiceReference.Message message = new ChatIBOXClient.ServiceReference.Message();
            message.Content = textBoxContent.Text.ToString();
            proxySingleton.Whisper(message, receiver);  
        }
    }
}
